#include <dbg.h>

#include <cassert>
#include <string>

using namespace std;

class Solution {
public:
    int maxVowels(string s, int k) {
        int sum = 0;
        for (int i = 0; i < k; ++i) {
            if (isVowels(s[i])) {
                ++sum;
            }
        }

        int maxVowel = sum;
        for (int i = k; i < s.size(); ++i) {
            sum += isVowels(s[i]) - isVowels(s[i - k]);
            maxVowel = max(sum, maxVowel);
        }

        return maxVowel;
    }

private:
    int isVowels(char c) {
        return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u';
    }
};

int main() {
    Solution s;

    string s1 = "abciiidef";
    string s2 = "aeiou";
    string s3 = "leetcode";
    string s4 = "rhythms";
    string s5 = "tryhard";
    string s6 = "ibpbhixfiouhdljnjfflpapptrxgcomvnb";

    assert(s.maxVowels(s1, 3) == 3);
    assert(s.maxVowels(s2, 2) == 2);
    assert(s.maxVowels(s3, 3) == 2);
    assert(s.maxVowels(s4, 4) == 0);
    assert(s.maxVowels(s5, 4) == 1);
    assert(s.maxVowels(s6, 33) == 7);

    return 0;
}